<?php
	include_once "config_db.php";
	
	$database = 'mymap';
	
	if (!mysql_connect($db_host, $db_user, $db_pwd))
	die("Can't connect to database");
	
	if (!mysql_select_db($database))
	die("Can't select database");
	
	mysql_query("SET NAMES 'utf8'");
	$function_name = $_REQUEST["function_name"];

	if($function_name == "getLastID") {
		$table_input = $_REQUEST["table_input"];
		getLastID($table_input);
	}
	function getLastID($table_input) {
		$result = mysql_query("SELECT id FROM {$table_input}");
		if(mysql_num_rows($result) == 0) {
			$return['id'] = 0;
		} else {
			while($data = mysql_fetch_array($result)) {
				$return['id'] = $data["id"];
			}	
		}
		echo json_encode($return);
	}
?>